package top.zsyle.sycc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import top.zsyle.sycc.doc.CourseDoc;
import top.zsyle.sycc.dto.CourseSearchDto;
import top.zsyle.sycc.result.JsonResult;
import top.zsyle.sycc.service.IEsCourseService;

@RestController
@RequestMapping("/esCourse")
public class EsCourseController {

    @Autowired
    private IEsCourseService esCourseService;

    @RequestMapping(value="/save",method= RequestMethod.POST)
    public JsonResult save(@RequestBody CourseDoc courseDoc){
        esCourseService.save(courseDoc);
        return JsonResult.success();
    }

    /**
     * es搜索
     * @param dto
     * @return
     */
    @RequestMapping(value="/search",method= RequestMethod.POST)
    public JsonResult search(@RequestBody CourseSearchDto dto){
        return JsonResult.success(esCourseService.search(dto));
    }

}
